package com.neusoft.cmsprojects.model;

import java.sql.Timestamp;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import com.opensymphony.xwork2.ActionContext;


/**
 * TbUser entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "user", catalog = "cms")
public class TbUser implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	
	private Integer cid;
	//用户名
	private String cusername;
	//密码
	private String cpassword;
	//昵称
	private String cshowname;
	//电话
	private String ctele;
	//邮件
	private String cemail;
	//等级
	private Integer clevel;
	//注册登录时间
	private Timestamp cregtime;
	//最后登录时间
	private String clogintime;
	
	private Set<Role> role=new HashSet<Role>();   //本类与Role 为多对多的关系

	@Id
	@GeneratedValue
	public Integer getCid() {
		return cid;
	}
	public void setCid(Integer cid) {
		this.cid = cid;
	}
	public String getCusername() {
		return cusername;
	}
	public void setCusername(String cusername) {
		this.cusername = cusername;
	}
	public String getCpassword() {
		return cpassword;
	}
	public void setCpassword(String cpassword) {
		this.cpassword = cpassword;
	}
	public String getCshowname() {
		return cshowname;
	}
	public void setCshowname(String cshowname) {
		this.cshowname = cshowname;
	}
	public String getCtele() {
		return ctele;
	}
	public void setCtele(String ctele) {
		this.ctele = ctele;
	}
	public String getCemail() {
		return cemail;
	}
	public void setCemail(String cemail) {
		this.cemail = cemail;
	}
	public Integer getClevel() {
		return clevel;
	}
	public void setClevel(Integer clevel) {
		this.clevel = clevel;
	}
	public Timestamp getCregtime() {
		return cregtime;
	}
	public void setCregtime(Timestamp cregtime) {
		this.cregtime = cregtime;
	}
	public String getClogintime() {
		return clogintime;
	}
	public void setClogintime(String clogintime) {
		this.clogintime = clogintime;
	}
	
	@ManyToMany(fetch=FetchType.EAGER)
	@JoinTable(
			name="tbuser_role",
			joinColumns={@JoinColumn(name="userid")}
			,inverseJoinColumns={@JoinColumn(name="roleid")}
			)
	public Set<Role> getRole() {
		return role;
	}
	public void setRole(Set<Role> role) {
		this.role = role;
	}
	
	
}
